package com.tiantianfresh.view.controller;

import com.tiantianfresh.model.pojo.*;
import com.tiantianfresh.view.service.HomePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author FANGAO
 * @date 2021/11/20 - 下午 15:13
 */
@Controller
@RequestMapping("/index")
public class HomePageController {

    @Autowired
    private HomePageService homePageService;

    @ResponseBody
    @RequestMapping("/categorygroupingAll")
    public Object queryAllCategorygrouping() {
        List<Categorygrouping> list = homePageService.queryAllCategorygrouping();
        AJAXResult result = new AJAXResult();
        result.setData(list);
        return result;
    }
    @ResponseBody
    @RequestMapping("/commodityAll")
    public Object queryAllCommodity() {
        List<CommodityResult> list = homePageService.queryAllCommodity();
        AJAXResult result = new AJAXResult();
        result.setData(list);
        return result;
    }
    @ResponseBody
    @RequestMapping("/rotationchartAll")
    public Object queryAllRotationchart() {
        List<Rotationchart> list = homePageService.queryAllRotationchart();
        AJAXResult result = new AJAXResult();
        result.setData(list);
        return result;
    }

    @ResponseBody
    @RequestMapping("/queryCategorygroupingCommodity")
    public Object queryCategorygroupingCommodity() {
        List<CategorygroupingCommodity> queryCategorygroupingCommodities = homePageService.queryCategorygroupingCommodity();
        AJAXResult result = new AJAXResult();
        if (queryCategorygroupingCommodities!=null){
            result.setSuccess(true);
            result.setData(queryCategorygroupingCommodities);
        }else{
            result.setSuccess(false);
        }
        return result;
    }
}
